package com.yutian.endecryption.mock.sql;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

/**
 * 伪数据相关 SQL语句构建器
 *
 * @author zhang peng yang ming
 * @create 2017-08-04 10:42
 */
 public class MockDataSqlProvider {
    public String delete(@Param("ksySfzmhm") String ksySfzmhm, @Param("ksyName") String ksyName, @Param("detailDlr") String detailDlr) {
        // DELETE FROM vt_examiner_record_info WHERE (sfzmhm=?)
        // DELETE FROM vt_examinee_info WHERE (ksy1=?)
        // DELETE FROM vt_subgroup_info WHERE (ksy=?)
        // DELETE FROM vt_subgroup_detail_info WHERE (dlr=?)
        // DELETE FROM vt_verification WHERE (ksysfzmhm=?)
        // DELETE FROM vt_score WHERE (ksysfzmhm=?)
        return new SQL() {  // 删除考官备案信息
            {
                DELETE_FROM("vt_examiner_record_info");
                WHERE("sfzmhm=#{ksySfzmhm}");
            }
        }.toString() + new SQL() {  // 删除学员预约信息
            {
                DELETE_FROM("vt_examinee_info");
                WHERE("ksy1=#{ksyName}");
            }
        }.toString() + new SQL() {  //删除分组信息
            {
                DELETE_FROM("vt_subgroup_info");
                WHERE("ksy=#{ksyName}");
            }
        }.toString() + new SQL() {  //删除分组明细
            {
                DELETE_FROM("vt_subgroup_detail_info");
                WHERE("dlr=#{detailDlr}");
            }
        }.toString() + new SQL() {  //删除科目开始结束
            {
                DELETE_FROM("vt_verification");
                WHERE("ksysfzmhm=#{ksySfzmhm}");
            }
        }.toString() + new SQL() {  //删除分数表
            {
                DELETE_FROM("vt_score");
                WHERE("ksysfzmhm=#{ksySfzmhm}");
            }
        }.toString();
    }

    /**
     * 根据考生身份证号码删除上传信息,签到信息, 项目开始结束信息
     *
     * @param sfzmhm
     * @return
     */
    public String deleteUplodeSignItem(@Param("vtUploadSfzmhm") String vtUploadSfzmhm, @Param("sfzmhm") String sfzmhm) {
        return new SQL() {  // 删除考官备案信息
            {
                DELETE_FROM("vt_upload");
                WHERE("sfzmhm=#{vtUploadSfzmhm}");
            }
        }.toString() + new SQL() {  // 删除签到信息
            {
                DELETE_FROM("vt_sign_in_info");
                WHERE("sfzmhm=#{sfzmhm}");
            }
        }.toString() + new SQL() {  // 删除签到信息
            {
                DELETE_FROM("vt_item_start_or_end");
                WHERE("sfzmhm=#{sfzmhm}");
            }
        }.toString();
    }
}
